//
//  TextNode.m
//  iFlickr
//
//  Created by 张 霄鹤 on 09-7-5.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "TextNode.h"


@implementation TextNode

@synthesize text;

/**
 * 通过文字创建节点
 */
+ (id)textNodeWithText:(NSString *)str{
	TextNode *ret = nil;
	ret = [[TextNode alloc] initWithText:str];
	return [ret autorelease];
}

- (id)initWithText:(NSString *)str{
	if(self = [super init]){
		text = [[NSMutableString alloc] init];
		[text appendString:str];
	}
	return self;
}

/**
 * 获取节点名称
 */
- (NSString *)getNodeName{
	return @"#TEXT";
}

- (NSInteger)nodeType{
	return TEXT_NODE;
}


- (BOOL)appendChild:(Node *)child{
	// 文本节点不允许添加子节点
	return NO;
}

- (BOOL)appendText:(NSString *)str{
	[text appendString:str];
	return YES;
}

- (NSString *)getValue{
	return text;
}

- (NSString *)toXML{
	return text;
}

- (void)dealloc{
	[text release];
	[super dealloc];
}

@end
